﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Management.Automation;

namespace Quest.FIMPowerShellSnapin
{
    /// <summary>
    /// Class that defines the New-FIMSession cmdlet
    /// </summary>
    [Cmdlet(VerbsCommon.New, Constants.Nouns.FIMSession)]
    public class NewFIMSession : PSCmdlet
    {
        [Parameter(ValueFromPipeline = true)]
        [ValidateNotNullOrEmpty]
        public PSCredential Credential
        {
            get;
            set;
        }

        [Parameter(Mandatory = true)]
        [ValidateNotNullOrEmpty]
        public string Server
        {
            get;
            set;
        }

        /// <summary>
        /// Use the Server and Credential parameters to create a new FIMPSSession, and output that to the Powershell pipeline. Allow the
        /// PS host to handle any exceptions.
        /// </summary>
        protected override void ProcessRecord()
        {
            FIMPSSession session = new FIMPSSession(Server, Credential, Host);
            WriteObject(session);
        }
    }
}
